extends Card

func init():
    att.atk = 3 #卡牌的攻击力
    att.maxHp = 2 #卡牌的生命值
    att.cry = 2 #卡牌的费用
    lv = 2 #卡牌的等级  2为蓝色 卓越  最高4 传说
    type = TYPE.CREATURE #卡牌类型
    camp = "m_hearthstone" #阵营
    name = "飞刀杂耍者" #卡牌名称
    tab = "" #卡牌的类别标签
    dec = "在你召唤一个随从后，随机对一个敌人造成1点伤害。" #卡牌的效果描述
    isTrig = true

func _connect():
    sys.scene.connect("onCardInDeck",self,"handleCardInDeck")

func handleCardInDeck(card,deck):
    # 进入我方战场
    if deck == getHero().bt:
        var targets = []
        # 获取敌方战场所有随从
        for i in card.getHero().getOppHero().bt.items:
            if i.att.hp > 0:
                targets.append(i)
        # 获取敌方英雄
        targets.append(card.getHero().getOppHero())
        # 随机得到一个目标
        var target = sys.rndListItem(targets)
        animTrig()
        sys.scene.queueFunc(self,"eff",1.0,[target.getPos()]) # 触发特效
        hurtCard(target,1,false)

# 特效
func eff(pos):
    var eff = sys.scene.newEff("e_feiDang")
    eff.play("fei",false)
    eff.position = getPos()
    eff.lookAt(pos)
    eff.MoveTo(pos,2000,false)
    yield(eff,"onMoveEnd")
    sys.scene.funcTime = 0.0
    eff.lookAt()
    eff.play("bao")